package com.dalin.platform.loa.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Transient;

import com.dalin.common.base.BaseObject;
import com.dalin.platform.pub.PlatContext;
/*****************************************************************************
 * @content: 类信息                                                                                                                                *
 * @author : 那建林                                                                                                                                 *
 * @crtDate: 2011-03-04 13:21:40                                            *
 * @modDate: 2011-03-04 13:21:40                                            *
 * @version: 1.00                                                           *
 ****************************************************************************/
@Entity
@Table(name="LOA_OPERATE_HEADER")
public class LoaOperateHeaderEntity extends BaseObject{
    private Long lohId; // LOH_ID,16,0,null
    private Long headerId; // HEADER_ID,16,0,null
    private Integer headerWidth; // HEADER_WIDTH,8,0,null
    private Long operateId; // OPERATE_ID,16,0,null
    private Integer hidden; // HIDDEN,8,0,null
    private Integer orderNumber; // ORDER_NUMBER,8,0,null



    @Id
    @Column(name="LOH_ID")
    @GeneratedValue(strategy = GenerationType.TABLE,generator="generator_normal")
    @TableGenerator(
        name = "generator_normal",
        table = "GLB_GENERATOR_KEY",
        pkColumnName = "GEN_KEY",
        valueColumnName = "GEN_VALUE",
        pkColumnValue = "LOA_OPERATE_HEADER",
        allocationSize=1
    )
    public Long getLohId() {
        return lohId;
    }

    public void setLohId(Long lohId) {
        this.lohId = lohId;
    }

    @Column(name="HEADER_ID")
    public Long getHeaderId() {
        return headerId;
    }

    public void setHeaderId(Long headerId) {
        this.headerId = headerId;
    }

    @Column(name="HEADER_WIDTH")
    public Integer getHeaderWidth() {
        return headerWidth;
    }

    public void setHeaderWidth(Integer headerWidth) {
        this.headerWidth = headerWidth;
    }

    @Column(name="OPERATE_ID")
    public Long getOperateId() {
        return operateId;
    }

    public void setOperateId(Long operateId) {
        this.operateId = operateId;
    }

    @Column(name="HIDDEN")
    public Integer getHidden() {
        return hidden;
    }

    public void setHidden(Integer hidden) {
        this.hidden = hidden;
    }

    @Column(name="ORDER_NUMBER")
    public Integer getOrderNumber() {
        return orderNumber;
    }

    public void setOrderNumber(Integer orderNumber) {
        this.orderNumber = orderNumber;
    }

    
    @Transient
    public LoaPublicHeaderEntity getGridHeaderEntity() {
		return  PlatContext.getDao().findObjById(
				LoaPublicHeaderEntity.class, this.getHeaderId());
	}

	
	
	@Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof LoaOperateHeaderEntity)) return false;
        final LoaOperateHeaderEntity other = (LoaOperateHeaderEntity) o;
        if (lohId == null) {
            if (other.lohId != null) return false;
        } else if (!lohId.equals(other.lohId)) {
            return false;
        }
        if (headerId == null) {
            if (other.headerId != null) return false;
        } else if (!headerId.equals(other.headerId)) {
            return false;
        }
        if (headerWidth == null) {
            if (other.headerWidth != null) return false;
        } else if (!headerWidth.equals(other.headerWidth)) {
            return false;
        }
        if (operateId == null) {
            if (other.operateId != null) return false;
        } else if (!operateId.equals(other.operateId)) {
            return false;
        }
        if (hidden == null) {
            if (other.hidden != null) return false;
        } else if (!hidden.equals(other.hidden)) {
            return false;
        }
        if (orderNumber == null) {
            if (other.orderNumber != null) return false;
        } else if (!orderNumber.equals(other.orderNumber)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int njlrst = 17;
        njlrst = 31 * njlrst + (lohId == null ? 0 : lohId.hashCode());
        njlrst = 31 * njlrst + (headerId == null ? 0 : headerId.hashCode());
        njlrst = 31 * njlrst + (headerWidth == null ? 0 : headerWidth.hashCode());
        njlrst = 31 * njlrst + (operateId == null ? 0 : operateId.hashCode());
        njlrst = 31 * njlrst + (hidden == null ? 0 : hidden.hashCode());
        njlrst = 31 * njlrst + (orderNumber == null ? 0 : orderNumber.hashCode());
        return njlrst;
    }

}
